package com.example.backend.service;


import com.example.backend.mapper.DepositMapper;
import com.example.backend.model.Deposit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DepositService {
    @Autowired
    private DepositMapper depositMapper;

    // 新增存款信息
    @Transactional
    public int addDeposit(Deposit deposit) {
        return depositMapper.insertDeposit(deposit);
    }

    // 根据savingID删除存款信息
    @Transactional
    public int deleteDepositBySavingID(Integer savingID) {
        return depositMapper.deleteDepositBySavingID(savingID);
    }

    // 根据savingID更新存款信息
    @Transactional
    public int updateDepositBySavingID(Deposit deposit) {
        return depositMapper.updateDepositBySavingID(deposit);
    }

    // 根据savingID查询存款信息
    public Deposit getDepositBySavingID(Integer savingID) {
        return depositMapper.selectDepositBySavingID(savingID);
    }

    // 查询所有存款信息
    public List<Deposit> getAllDeposits() {
        return depositMapper.selectAllDeposits();
    }
}